package com.kingyun.gpsinspection.purificationservice.services.tdm.innerservice.impl;

import com.alibaba.fastjson.JSON;
import com.kingyun.gpsinspection.purificationservice.dao.mapper.tdm.SecurityCheckProblemMapper;
import com.kingyun.gpsinspection.purificationservice.facade.model.tdm.SecurityCheckProblemVo;
import com.kingyun.gpsinspection.purificationservice.facade.service.tdm.SecurityCheckProblemService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by deadministrator on 2016/11/23.
 * 安全检查体
 */
public class SecurityCheckProblemServiceImpl implements SecurityCheckProblemService{
    @Autowired
    public SecurityCheckProblemMapper securityCheckProblemMapper;

    /**
     * 查询
     * @param securityCheckProblem
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> list(SecurityCheckProblemVo securityCheckProblem) throws Exception{
        Map<String, Object> map = new HashMap<>();
        securityCheckProblem.setLimit( securityCheckProblem.getLimit() == null ? 10 : securityCheckProblem.getLimit() );
        securityCheckProblem.setOffset( securityCheckProblem.getOffset() == null ? 0 : securityCheckProblem.getOffset() );
        System.out.println("插入前主键为："+securityCheckProblem.getCheckProblemId());
        map.put("total",securityCheckProblemMapper.queryCount(securityCheckProblem));
        map.put("rows", JSON.toJSON(securityCheckProblemMapper.queryList(securityCheckProblem)));
        return map;
    }

    /**
     * 根据ID查询
     * @param checkProblemId
     * @return
     * @throws Exception
     */
    @Override
    public SecurityCheckProblemVo findSecurityCheckProblemId(String checkProblemId) throws Exception {
        return securityCheckProblemMapper.selectByPrimaryKey(checkProblemId);
    }
}
